function clearCalendarDate(codeTextId){
	document.getElementById(codeTextId).value = "";
}
 
//function doSubmit(formname, actionId) {
//	document.forms[formname].action = actionId;
//	document.forms[formname].submit();
//}

function setCheckBox(icount) {

	var iNum = 0;

	for (i = 0; i < icount; i++) {
		var chkDelColO = document.getElementById('chkDelCol' + i);
		if (chkDelColO != null) {
			if (chkDelColO.checked == true) {
				iNum++;
				break;
			}
		}
	}

	if (iNum > 0) {
		for (i = 0; i < icount; i++) {
			var chkDelColO = document.getElementById('chkDelCol' + i);
			if (chkDelColO != null) {
				chkDelColO.checked = false;
			}
		}
	} else {
		for (i = 0; i < icount; i++) {
			var chkDelColO = document.getElementById('chkDelCol' + i);
			if (chkDelColO != null) {
				chkDelColO.checked = true;
			}
		}
	}
}

function setParam(page, sortType, sortOrder) {
	var cSortType = document.getElementById('sortType').value;

	document.getElementById('cpage').value = page;
	document.getElementById('sortType').value = sortType;

	if (cSortType == sortType) {
		document.getElementById('sortOrder').value = sortOrder;
	} else {
		document.getElementById('sortOrder').value = 0;
	}
}

function searchWinPopup(targetFieldId, searchUrl, name) {
	 var width  = 720;
	 var height = 550;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;
	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=yes';
	 params += ', status=no';
	 params += ', toolbar=no';

	 searchUrl += '?back_id='+targetFieldId;

	 var newwin=window.open(searchUrl,name, params);

	 if (window.focus) {
		 newwin.focus();
	 }
}

function openWinMapFromPost(zipcode, searchUrl, name) {
	 var width  = 700;
	 var height = 600;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;
	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=no';
	 params += ', status=no';
	 params += ', toolbar=no';

	 searchUrl += '?zipcode='+zipcode;

	 var newwin=window.open(searchUrl,name, params);
}

function openWinMapFromAddress(address, searchUrl, name) {
	 var width  = 700;
	 var height = 600;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;
	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=no';
	 params += ', status=no';
	 params += ', toolbar=no';

	 searchUrl += '?address='+address;

	 var newwin=window.open(searchUrl,name, params);
}

function setBackTargetValue2Para(icount, keyId0, keyId1) {

	var iNum = 0;
	var iSelectRow = 0;

	for (i = 0; i < icount; i++) {
		var chkSelectColO = document.getElementById('chkSelectCol' + i);
		if (chkSelectColO != null) {
			if (chkSelectColO.checked == true) {
				iNum++;
				iSelectRow = i;
				break;
			}
		}
	}

	if (iNum > 0) {
		var targetFieldId0 = document.getElementById('targetField0').value;
		var targetFieldId1 = document.getElementById('targetField1').value;
		opener.document.getElementById(targetFieldId0).value = document.getElementById(keyId0 + '' + iSelectRow).value;
		opener.document.getElementById(targetFieldId1).value = document.getElementById(keyId1 + '' + iSelectRow).value;
		self.close();
		opener.document.getElementById(targetFieldId1).onchange();
		opener.focus();
		opener.document.getElementById(targetFieldId0).onchange();
	} else {
		alert('郢晢ｿｽ�ｽ郢ｧ�ｿ郢ｧ蟶昶�隰壽ｧｭ��ｸｺ�ｦ闕ｳ荵晢ｼ�ｸｺ�ｽ�ｽ');
	}

}

function setBackTargetValue2ParaFromButton(keyId0, keyId1, iSelectRow) {
	var targetFieldId0 = document.getElementById('targetField0').value;
	var targetFieldId1 = document.getElementById('targetField1').value;
	opener.document.getElementById(targetFieldId0).value = document.getElementById(keyId0 + '' + iSelectRow).value;
	opener.document.getElementById(targetFieldId1).value = document.getElementById(keyId1 + '' + iSelectRow).value;
	self.close();
	opener.document.getElementById(targetFieldId1).onchange();
	opener.focus();
	opener.document.getElementById(targetFieldId0).onchange();
}

function setBackTargetValue3ParaFromButton(keyId0, keyId1, keyId2, iSelectRow) {

	var targetFieldId0 = document.getElementById('targetField0').value;
	var targetFieldId1 = document.getElementById('targetField1').value;
	var targetFieldId2 = document.getElementById('targetField2').value;

	opener.document.getElementById(targetFieldId0).value = document.getElementById(keyId0 + '' + iSelectRow).value;
	opener.document.getElementById(targetFieldId1).value = document.getElementById(keyId1 + '' + iSelectRow).value;
	opener.document.getElementById(targetFieldId2).value = document.getElementById(keyId2 + '' + iSelectRow).value;
	self.close();
	opener.focus();
	opener.document.getElementById(targetFieldId1).onchange();
	opener.document.getElementById(targetFieldId0).onchange();
	opener.document.getElementById(targetFieldId2).onchange();
}

function setBackTargetValue(icount, keyId) {

	var iNum = 0;
	var iSelectRow = 0;

	for (i = 0; i < icount; i++) {
		var chkSelectColO = document.getElementById('chkSelectCol' + i);
		if (chkSelectColO != null) {
			if (chkSelectColO.checked == true) {
				iNum++;
				iSelectRow = i;
				break;
			}
		}
	}
	if (iNum > 0) {
		var targetFieldId = document.getElementById('targetField').value;
		opener.document.getElementById(targetFieldId).value = document.getElementById(keyId + '' + iSelectRow).value;
		self.close();
		opener.document.getElementById(targetFieldId).onchange();
		opener.focus();
	} else {
		alert('郢晢ｿｽ�ｽ郢ｧ�ｿ郢ｧ蟶昶�隰壽ｧｭ��ｸｺ�ｦ闕ｳ荵晢ｼ�ｸｺ�ｽ�ｽ');
	}
}

function setBackTargetValueFromButton(keyId,iSelectRow) {

	var targetFieldId = document.getElementById('targetField').value;
	opener.document.getElementById(targetFieldId).value = document.getElementById(keyId + '' + iSelectRow).value;
	self.close();
	opener.document.getElementById(targetFieldId).onchange();
	opener.focus();

}

//function doSortData(formname, actionId, checkSortAllFieldName, sortActionId) {
//	if (document.getElementById(checkSortAllFieldName).checked == false) {
//		document.forms[formname].action = sortActionId;
//		document.forms[formname].submit();
//	} else {
//		document.forms[formname].action = actionId;
//		document.forms[formname].submit();
//	}
//}

function doSortData(formname, actionId, checkSortAllFieldName, sortActionId) {		
		document.forms[formname].action = actionId;
		document.forms[formname].submit();
}

function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-1000px';
    scr.style.left = '-1000px';
    scr.style.width = '100px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '200px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;

    // Remove the scrolling div from the doc
    document.body.removeChild(
        document.body.lastChild);

    // Pixel width of the scroller
    return (wNoScroll - wScroll);
}


var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strYear=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(pos2+1)
	strYr=strYear

	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)

	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}

	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : yyyy/mm/dd")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between " + minYear + " and " + maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//alert("Please enter a valid date")
		return false
	}

	return true
}

function validateDate(txtDateFieldId) {

	var strDate = document.getElementById(txtDateFieldId).value;

	if (isDate(strDate) == false) {
		document.getElementById(txtDateFieldId).value = '';
	}
}

function rightPadString(txtString, lengthRequired){
	txtString = txtString + " ";
	while (txtString.length<lengthRequired - 1){
		txtString += " ";
	}
	return txtString;
}

function searchWinPopup2Para(targetFieldId0, targetFieldId1, searchUrl, name) {

	var width  = 720;
	 var height = 550;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;

	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=yes';
	 params += ', status=no';
	 params += ', toolbar=no';

	 searchUrl += '?back_id0='+targetFieldId0;
	 searchUrl += '&back_id1='+targetFieldId1;
	 searchUrl += '&back_id2='+document.getElementById(targetFieldId0).value;

	 var newwin=window.open(searchUrl,name, params);

	 if (window.focus) {
		 newwin.focus();
	 }
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

function searchWinPopup3Para(targetFieldId0, targetFieldId1, targetFieldId2, searchUrl, name) {

	 var width  = 720;
	 var height = 550;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;

	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=yes';
	 params += ', scrollbars=yes';
	 params += ', status=no';
	 params += ', toolbar=no';

	 searchUrl += '?back_id0=' + targetFieldId0;
	 searchUrl += '&back_id1=' + targetFieldId1;
	 searchUrl += '&back_id2=' + targetFieldId2;

	 if (document.getElementById(targetFieldId0).value) {
		 searchUrl += '&back_id3=' + document.getElementById(targetFieldId0).value.trim();
	 } else {
		 searchUrl += '&back_id3=' + '';
	 }

	 if (document.getElementById(targetFieldId1).value) {
		 searchUrl += '&back_id4=' + document.getElementById(targetFieldId1).value.trim();
	 } else {
		 searchUrl += '&back_id4=' + '';
	 }

	 var newwin=window.open(searchUrl, name, params);

	 if (window.focus) {
		 newwin.focus();
	 }
}


function doUrl(url) {
	window.location.href = url;
}

function compareDate(date1, date2) {
	if (date1 > date2) {
		return true;
	} else {
		return false;
	}
}

function confirmFromDate(dateFromId, dateToId) {

	dateFrom = document.getElementById(dateFromId).value;
	dateTo = document.getElementById(dateToId).value;

	if (compareDate(dateFrom, dateTo) == true && dateTo != '') {
		document.getElementById(dateToId).value = dateFrom;
	}
}

function confirmToDate(dateFromId, dateToId) {

	dateFrom = document.getElementById(dateFromId).value;
	dateTo = document.getElementById(dateToId).value;

	if (compareDate(dateFrom, dateTo) == true && dateFrom != '') {
		document.getElementById(dateFromId).value = dateTo;
	}
}

function clearInputDataArea(txtId1, txtId2,spanId, spanHiddenId) {
	if (txtId1 != null && document.getElementById(txtId1) != null && document.getElementById(txtId1).value != null)
		document.getElementById(txtId1).value = '';
	if (txtId2 != null && document.getElementById(txtId2) != null && document.getElementById(txtId2).value != null)
		document.getElementById(txtId2).value = '';
	if (spanId != null && document.getElementById(spanId) != null && document.getElementById(spanId).innerHTML != null)
		document.getElementById(spanId).innerHTML = '';
	if (spanHiddenId != null && document.getElementById(spanHiddenId) != null && document.getElementById(spanHiddenId).value != null)
		document.getElementById(spanHiddenId).value = '';
}
function clearInputData(txtId, spanId, spanHiddenId) {
	if (txtId != null && document.getElementById(txtId) != null && document.getElementById(txtId).value != null)
		document.getElementById(txtId).value = '';
	if (spanId != null && document.getElementById(spanId) != null && document.getElementById(spanId).innerHTML != null)
		document.getElementById(spanId).innerHTML = '';
	if (spanHiddenId != null && document.getElementById(spanHiddenId) != null && document.getElementById(spanHiddenId).value != null)
		document.getElementById(spanHiddenId).value = '';
}

function clearInputDataCust(txtId, spanId, spanId1,spanId2,spanHiddenId) {
	if (txtId != null && document.getElementById(txtId) != null && document.getElementById(txtId).value != null)
		document.getElementById(txtId).value = '';
	if (spanId != null && document.getElementById(spanId) != null && document.getElementById(spanId).innerHTML != null)
		document.getElementById(spanId).innerHTML = '';
	if (spanId1 != null && document.getElementById(spanId1) != null && document.getElementById(spanId1).innerHTML != null)
		document.getElementById(spanId1).innerHTML = '';
	if (spanId2 != null && document.getElementById(spanId2) != null && document.getElementById(spanId2).innerHTML != null)
		document.getElementById(spanId2).innerHTML = '';
	if (spanHiddenId != null && document.getElementById(spanHiddenId) != null && document.getElementById(spanHiddenId).value != null)
		document.getElementById(spanHiddenId).value = '';
}

function clearCalendarData(txtId) {
	if (document.getElementById(txtId)) {
		document.getElementById(txtId).value = '';
	}
}

function checkCheckboxFromZeroToCount(field,count){
	var objCheckBoxes = document.forms[0].elements[field];

	if(!objCheckBoxes)
		return;

	for(var i = 0; i < count; i++)
		objCheckBoxes[i].checked = true;
}

function checkAllCheckbox(field){
	var objCheckBoxes = document.forms[0].elements[field];

	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = true;
	else
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = true;
}

function uncheckAllCheckbox(field){
	var objCheckBoxes = document.forms[0].elements[field];

	if(!objCheckBoxes)
		return;
	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = false;
	else
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = false;
}

function notChangeOption(optionId, value)
{
	document.getElementById(optionId).value = value;
	return false;
}

function nvl(value) //Oracle NVL鬮｢�｢隰ｨ�ｰ 邵ｺ�ｫ闔ｨ�ｼ邵ｺ�ｦ邵ｺ�ｽ�狗ｸｲ�ｽ
{
	if (value == null)
		return '';
	else
		return value;
}

function notChangeList(listId, value)
{
	if ((value + "").trim().length == 0)
		document.getElementById(listId).value = "";
	else if ((value + "").length < 2){
		value = rightPadString(value,2);
		document.getElementById(listId).value = value;
	}
}

function formatAddColorNumbericLabel(id){
	if(document.getElementById(id).innerHTML != null){
		var numberVal = 0;
		numberVal = document.getElementById(id).innerHTML;

		if(IsNumeric(numberVal)){
			if(numberVal<0){
				document.getElementById(id).innerHTML = formatFloat2(numberVal);
				document.getElementById(id).style.color = "red";
			}else{
				document.getElementById(id).innerHTML = formatFloat2(numberVal);
				document.getElementById(id).style.color = "black";
			}
		}
	}
}

function formatAddColorNumbericText(id){
	if(document.getElementById(id).value != null){
		var numberVal = 0;
		numberVal = document.getElementById(id).value;

		if(IsNumeric(numberVal)){
			if(numberVal<0){
				document.getElementById(id).value = formatInt(numberVal);
				document.getElementById(id).style.color = "red";
			}else{
				document.getElementById(id).value = formatInt(numberVal);
				document.getElementById(id).style.color = "black";
			}
		}
	}
}

function changeColorOfNumberic(id){
	if (document.getElementById(id).value != null){
		var numberVal = 0;
		numberVal = document.getElementById(id).value;
		if(IsNumeric(numberVal) && numberVal<0){
			document.getElementById(id).style.color = "red";
			return false;
		}
	}
	document.getElementById(id).style.color = "black";
	return false;
}

function IsNumeric(sText)
{
	var ValidChars = "0123456789.-+";
	var IsNumber=true;
	var Char;

	for (i = 0; i < sText.length && IsNumber == true; i++)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}
//format number 10000 -> 10,000.00
function FormatNumber(num,decimalNum,bolLeadingZero,bolParens,bolCommas)
/**********************************************************************
	IN:
		NUM - the number to format
		decimalNum - the number of decimal places to format the number to
		bolLeadingZero - true / false - display a leading zero for
										numbers between -1 and 1
		bolParens - true / false - use parenthesis around negative numbers
		bolCommas - put commas as number separators.

	RETVAL:
		The formatted number!
 **********************************************************************/
{
        if (isNaN(parseInt(num))) return "NaN";

	var tmpNum = num;
	var iSign = num < 0 ? -1 : 1;		// Get sign of number

	// Adjust number so only the specified number of numbers after
	// the decimal point are shown.
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.round(Math.abs(tmpNum))
	tmpNum /= Math.pow(10,decimalNum);
	tmpNum *= iSign;					// Readjust for sign


	// Create a string object to do our formatting on
	var tmpNumStr = new String(tmpNum);

	// See if we need to strip out the leading zero or not.
	if (!bolLeadingZero && num < 1 && num > -1 && num != 0)
		if (num > 0)
			tmpNumStr = tmpNumStr.substring(1,tmpNumStr.length);
		else
			tmpNumStr = "-" + tmpNumStr.substring(2,tmpNumStr.length);

	// See if we need to put in the commas
	if (bolCommas && (num >= 1000 || num <= -1000)) {
		var iStart = tmpNumStr.indexOf(".");
		if (iStart < 0)
			iStart = tmpNumStr.length;

		iStart -= 3;
		while (iStart >= 1) {
			tmpNumStr = tmpNumStr.substring(0,iStart) + "," + tmpNumStr.substring(iStart,tmpNumStr.length)
			iStart -= 3;
		}
	}

	// See if we need to use parenthesis
	if (bolParens && num < 0)
		tmpNumStr = "(" + tmpNumStr.substring(1,tmpNumStr.length) + ")";

	tmpNumStr = tmpNumStr.replace(/-,/g,"-");

	return tmpNumStr;		// Return our formatted string!
}

function formatInt(aInt) {
   return FormatNumber(aInt, 0, false, false, true); 
}

function formatFloat2(aInt) {
	   return FormatNumber(aInt, 2, false, false, true);
}

function clearCombo(comboId) {
	document.getElementById(comboId).selectedIndex = -1;
}

function enableButton() {
   var ele = window.opener.document.forms[0].elements;
   for(var i = 0; i <ele.length;i++) {
    element = ele[i];
    if (element.type) {
      switch (element.type) {
	      case 'button':
	      case 'reset':
	      case 'submit':        	
	    	  element.disabled = '';
       }
     }
  }	
}

function disableButton() {
   var ele = document.forms[0].elements;
   for(var i = 0; i <ele.length;i++) {
    element = ele[i];
    if (element.type) {
      switch (element.type) {
	      case 'button':
	      case 'reset':
	      case 'submit':        	
	    	  element.disabled = 'disabled';
       }
     }
  }		
}

function copyName(name,Rname,lenRname, Tname, lenTname) {
	 var nameText = document.getElementById(name).value ;
	 var RnameText = document.getElementById(Rname).value ;
	 var TnameText = document.getElementById(Tname).value ;
	 if(RnameText == ""){
		 document.getElementById(Rname).value = nameText.substring(0,lenRname);
	 }
	 if(TnameText == ""){
		 document.getElementById(Tname).value = nameText.substring(0,lenTname);
	 }
}

function checkKataKana(e,id){
	var key = e.keyCode || e.which;
	if (key == 13) {	
		 var text = document.getElementById(id).value ;
		 var HANKAKUKANA = new RegExp("^([ｦ-ﾝ]|([ｶ-ﾄ]|[ﾊ-ﾎ])ﾞ|[ﾊ-ﾎ]ﾟ)*$");
		  if(!text.match(HANKAKUKANA)){
		 		alert('半角カタカナのみで入力して下さい。');
		 		document.getElementById(id).focus();
		  }
	}
}

function checkLenCode(id, lencode) {
	var text = document.getElementById(id).value;
	if (text.length >= lencode) {
		document.getElementById(id).value = document.getElementById(id).value.substring(0, lencode );
	}
 }

function checkMode() {
	var paramString = '';	
	paramString = paramString + 'strCode1' + '=' + document.getElementById('trOrdrh.ordrNo').value + '&'; 
	paramString = paramString + 'strCode2' + '=' + '' + '&'; 	
	paramString = paramString + 'strCode3' + '=' + '' + '&'; 
	paramString = paramString + 'strCode4' + '=' + ''; 
	var check = (getDataAjax('lookupData!getOrdrVo', paramString));
	if(check == '')return false;
	document.forms['OrderInputRegForm'].action = 'OrderInputReg!view';
	document.forms['OrderInputRegForm'].submit();
  }
  
function onchangeMode() {
	var value = document.getElementById('trOrdrh.ordrNo').value;
	var paramString = '';	
	paramString = paramString + 'strCode1' + '=' + document.getElementById('trOrdrh.ordrNo').value + '&'; 
	paramString = paramString + 'strCode2' + '=' + '' + '&'; 	
	paramString = paramString + 'strCode3' + '=' + '' + '&'; 
	paramString = paramString + 'strCode4' + '=' + ''; 
	var check = (getDataAjax('lookupData!getOrdrVo', paramString));
	if(check == ''){
		alert('データは存在していません');
	}else{
		document.forms['OrderInputRegForm'].action = 'OrderInputReg!view';
		document.forms['OrderInputRegForm'].submit();
	}
  }
  

  function displayCalendar(inputID, butonID){
	
	    $(inputID).datepicker({ 
	    	regional: "ja",
	    	//changeYear: true,
	    	//changeMonth: true,
	    	showButtonPanel: true    	
	    	//showOn: "both"
	    	//buttonImageOnly: true,
	    	//buttonText: "譌･莉�, 
	    	//buttonImage: "../js/Calendar/calendar.png"
	    	
	    });    
	    $(inputID).datepicker( "option", "showAnim", "fold" ); 
	    $(inputID).datepicker( "option", "dateFormat", "yy/mm/dd (D)");	
	    $(butonID).button().click(
	            function (){
	            	 $(inputID).focus();
	            }
	     );
}

function displayCalendarSearch(inputID){
	 if(!$(inputID).hasClass("addCalendar")){
		
	    $(inputID).datepicker({ 
	    	regional: "ja",	    	
	    	showButtonPanel: true    	
	    });    
	    //$(inputID).datepicker( "option", "showAnim", "fold" ); 
	    $(inputID).datepicker( "option", "dateFormat", "yy/mm/dd (D)");	   
	    $(inputID).datepicker("show");
	    //$(inputID).keypress(function(event) {event.preventDefault();});
	    
	    //$(inputID).attr( 'readOnly' , 'true' );

	    $(inputID).addClass("addCalendar");	
	    

	    
	   
	 }
}
function displayCalendarYearMonth(inputID){

	 if(!$(inputID).hasClass("addCalendar")){		
	    $(inputID).datepicker({ 
	    	regional: "ja",	    	
	    	showButtonPanel: true    	
	    });
	    var inputIDName = inputID.substring(1, inputID.length);
	    var tempYearMonth = document.getElementById(inputIDName).value ;
	    //$(inputID).datepicker( "option", "showAnim", "fold" ); 
	    $(inputID).datepicker( "option", "dateFormat", "yy/mm                             /dd");
	    document.getElementById(inputIDName).value = tempYearMonth;	    
	    $(inputID).datepicker("show");
	    //$(inputID).keypress(function(event) {event.preventDefault();});	    
	    //$(inputID).attr( 'readOnly' , 'true' );
	    $(inputID).addClass("addCalendar");
	    
	 }
}

function btnShowCalendarYearMonth(inputID){
	 if(!$(inputID).hasClass("addCalendar")){
		 displayCalendarYearMonth(inputID);
	 } else {
	   $(inputID).focus();
	 }
	       
}

function disableInputText()
{	
	  var code = event.keyCode;
	  if(code == 13 || code == 9)
		  return;
	  
	  event.returnValue=false;
      return;
	
}
/**
 * @author dang nhu tuan 
 * @param inputID: textfield input ID
 */
function displayCalendarSearchYYYYMM(inputID){
	 if(!$(inputID).hasClass("addCalendar")){
	    $(inputID).datepicker({ 
	    	regional: "ja",	    	
	    	showButtonPanel: true    	
	    });    
	    $(inputID).datepicker( "option", "dateFormat", "yy/mm");	   
	    $(inputID).datepicker("show");
	    $(inputID).addClass("addCalendar");		   
	 }
}

function btnShowCalendar(inputID){
	 if(!$(inputID).hasClass("addCalendar")){
		 displayCalendarSearch(inputID);
	 } else {
	   $(inputID).focus();
	 }
	       
}

/**
 * @author dang nhu tuan
 * @param inputID: textfield input ID
 */
function btnShowCalendarYyyyMm(inputID){
	 if(!$(inputID).hasClass("addCalendar")){
		 displayCalendarSearchYYYYMM(inputID);
	 } else {
	   $(inputID).focus();
	 }
}

function searchDialog(id, btnsearch,btnCancel, action){
	
	$( "#searchDiaglog:ui-dialog" ).dialog( "destroy" );
	$(document).ready(function(){
	    var htmldialog = $("#searchDiaglog").html(); 
		var dialogOpts = {
	        title: "",
	        modal: true,       
	        height: 700,
	        width: 700,      
	        bgiframe: true,
	        autoOpen: false,       
	        resizable: false,
	        draggable: false,     
			close: function(){$(this).html(htmldialog);}       
	        };
		$("#searchDiaglog").dialog(dialogOpts); 
	    $(btnsearch).button().click(	
	        function (e){
	        	$("#searchDiaglog").dialog("open");
	        	e.preventDefault();         	 
	        		  var options = {
			    		  target: "#searchDiaglog",
			    		  
			    		  success: function(data) {	
			    			
			    		  	$("#searchDiaglog").html(data);
			    		    reloadColorFocus();	
			              },
			              url: "MSearch!"+ action + "?codeText="+ id + "&valueText=" + document.getElementById(id).value
			    	  }		    
				$("#searchDiaglog").ajaxSubmit(options);        	  	
	            $("#searchDiaglog").dialog("open"); 
	            //window.scroll(100,100);   
	       });	
		   // browser IE
		    if (jQuery.browser.msie) {    	 
		    	  $(btnsearch).addClass("ui-search-button-ie");
		    	  $(btnCancel).addClass("ui-delete-button-ie");    	
		    } else { 
		    	  $(btnsearch).addClass("ui-search-button");
		    	  $(btnCancel).addClass("ui-delete-button");     
		    }	
		});
}

function searchDialogCust(id, btnsearch, btnCancel, action, cust1Type, cust2Type, cust3Type){
	
	$( "#searchDiaglog:ui-dialog" ).dialog( "destroy" );
	$(document).ready(function(){
	    var htmldialog = $("#searchDiaglog").html(); 
		var dialogOpts = {
	        title: "",
	        modal: true,       
	        height: 700,
	        width: 700,      
	        bgiframe: true,
	        autoOpen: false,       
	        resizable: false,
	        draggable: false,     
			close: function(){$(this).html(htmldialog);}       
	        };
		$("#searchDiaglog").dialog(dialogOpts); 
	    $(btnsearch).button().click(	
	        function (e){
	        	$("#searchDiaglog").dialog("open");
	        	e.preventDefault();         	 
	        		  var options = {
			    		  target: "#searchDiaglog",
			    		  
			    		  success: function(data) {	
			    			
			    		  	$("#searchDiaglog").html(data);
			    		    reloadColorFocus();	
			              },
			              url: "MSearch!"+ action + "?codeText="+ id + "&valueText=" + document.getElementById(id).value + "&cust1Type=" + cust1Type + "&cust2Type=" + cust2Type + "&cust3Type=" + cust3Type +"&random=" + Math.random()   
			    
			    	  }		    
				$("#searchDiaglog").ajaxSubmit(options);        	  	
	            $("#searchDiaglog").dialog("open"); 
	            //window.scroll(100,100);   
	       });
		   // browser IE
		    if (jQuery.browser.msie) {
		    	  $(btnsearch).addClass("ui-search-button-ie");
		    	  $(btnCancel).addClass("ui-delete-button-ie");    	
		    } else { 
		    	  $(btnsearch).addClass("ui-search-button");
		    	  $(btnCancel).addClass("ui-delete-button");     
		    }	
		});
}

/**
 * change label of check-box
 * @author dang nhu tuan
 * @param checkboxID
 * @param labelID
 */
function changeUseFlgLabel(checkboxID, labelID) {
	if(document.getElementById(checkboxID).checked == true){
		document.getElementById(labelID).innerHTML = '使用不可';
	} else {
		document.getElementById(labelID).innerHTML = '使用可能';
	}
}

/**
 * convert to the empty string when 'str' is null
 * @author dang nhu tuan
 * @param str
 * @returns
 */
function toEmptyIfNull(str){
	if(str == null){
		return '';
	}else{
		return str;
	}
}

/**
 * limit number of rows character input in textarea box 
 * @author ANHDN
 * @param element, event
 * @returns
 */
function limitLines(obj, e) {
	  var keynum;
    // IE
    if(window.event) {
      keynum = e.keyCode;
    // Netscape/Firefox/Opera
    } else if(e.which) {
      keynum = e.which;
    }

    if(keynum == 13) {
  	var text = obj.value;
      var lines = text.split('\n');
                  
      if(lines.length == obj.rows) {
        return false;
      }
    }
  }



/**
 * limit number of rows character input in textarea box ,character number in one row
 * @author QUANGPV
 * @param element, event
 * @returns
 */

function limitTextarea(el, maxLines, maxChar) {
    if (!el.x) {
        el.x = uniqueInt();
        el.onblur = function() { clearInterval(window['int' + el.x]) }
    }
    window['int' + el.x] = setInterval(function() {
        var lines = el.value.replace(/\r/g, '').split('\n'), i = lines.length, lines_removed, char_removed;
        if (maxLines && i > maxLines) {
           // alert(' maxLines + ' lines');
            lines = lines.slice(0, maxLines);
            lines_removed = 1
        }
        if (maxChar) {
            i = lines.length;
            while (i-- > 0){
            	if(lines.length== maxLines){
            		if (lines[i].length > maxChar+2) {
                        lines[i] = lines[i].slice(0, maxChar + 2);
                        char_removed = 1
                    }
            	}else{
            		 if (lines[i].length > maxChar) {
                         lines[i] = lines[i].slice(0, maxChar);
                         char_removed = 1
                     }
            	}
            }
           
            if (char_removed) {
               // alert('maxChar + ' characters per line');
            	
            }
        }
        if (char_removed || lines_removed) el.value = lines.join('\n')
    }, 50);
}

function uniqueInt() {
    var num, maxNum = 100000;
    if (!uniqueInt.a || maxNum <= uniqueInt.a.length) uniqueInt.a = [];
    do num = Math.ceil(Math.random() * maxNum);
    while (uniqueInt.a.hasMember(num))
    uniqueInt.a[uniqueInt.a.length] = num;
    return num
}

Array.prototype.hasMember = function(testItem) {
    var i = this.length;
    while (i-- > 0) if (testItem == this[i]) return 1;
    return 0
};

function set_ie_alert() {
    window.alert = function(msg_str) {
        vb_alert(msg_str)
    }
}


function reloadColorFocus() {
	setListner("focus",setBKColor);
	setListner("blur",reSetBKColor);
	setListner("mouseover",setButtonOn);
	setListner("mouseout",setButtonOff);
	setListner("keypress",tabE);	

}

function upperCase(This){
	This.value = This.value.toUpperCase()
	return
}

function getMSG(idmesage){
	var paramString = '';	
	paramString = paramString + 'strCode1' + '=' + idmesage + '&'; 
	paramString = paramString + 'strCode2' + '=' + '' + '&';  	
	paramString = paramString + 'strCode3' + '=' + '' + '&'; 
	paramString = paramString + 'strCode4' + '=' + ''; 
	var mes = (getDataAjax('lookupData!getMSG', paramString));
	
	return mes;
	
}
